﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing.Imaging; 
using iTextSharp.text.rtf;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Image=iTextSharp.text.Image;

public partial class pages_Demo_pdf_GenPDF : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        

        Console.WriteLine("Chapter 4 example 4: Simple Graphic");

        // step 1: creation of a document-object
        Document document = new Document();

        try
        {

            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file

            PdfWriter.GetInstance(document, new FileStream("Chap0404.pdf", FileMode.Create));

            // step 3: we open the document
            document.Open();
            document.AddTitle("this is a test title");
            // step 4: we add a Graphic to the document
            Image grx = Image.GetInstance(new Uri("http://218.25.155.55:8070/images/tony_top1.jpg"));
            
            document.Add(grx);

        }
        catch (DocumentException de)
        {
            Console.Error.WriteLine(de.Message);
        }
        catch (IOException ioe)
        {
            Console.Error.WriteLine(ioe.Message);
        }

        // step 5: we close the document
        document.Close();

    }
}
